package com.ruoyi.event.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.event.domain.EventMyList;
import com.ruoyi.event.service.IEventMyListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报名活动信息Controller
 * 
 * @author ruoyi
 * @date 2025-10-17
 */
@RestController
@RequestMapping("/event/myeventlist")
public class EventMyListController extends BaseController
{
    @Autowired
    private IEventMyListService eventMyListService;

    /**
     * 查询报名活动信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EventMyList eventMyList)
    {
        startPage();
        List<EventMyList> list = eventMyListService.selectEventMyListList(eventMyList);
        return getDataTable(list);
    }

    /**
     * 导出报名活动信息列表
     */
    @PreAuthorize("@ss.hasPermi('event:myeventlist:export')")
    @Log(title = "报名活动信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EventMyList eventMyList)
    {
        List<EventMyList> list = eventMyListService.selectEventMyListList(eventMyList);
        ExcelUtil<EventMyList> util = new ExcelUtil<EventMyList>(EventMyList.class);
        util.exportExcel(response, list, "报名活动信息数据");
    }

    /**
     * 获取报名活动信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eventMyListService.selectEventMyListById(id));
    }

    /**
     * 新增报名活动信息
     */
    @Log(title = "报名活动信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EventMyList eventMyList)
    {
        return toAjax(eventMyListService.insertEventMyList(eventMyList));
    }

    /**
     * 修改报名活动信息
     */
    @Log(title = "报名活动信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EventMyList eventMyList)
    {
        return toAjax(eventMyListService.updateEventMyList(eventMyList));
    }

    /**
     * 删除报名活动信息
     */
    @Log(title = "报名活动信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eventMyListService.deleteEventMyListByIds(ids));
    }
}
